﻿using Lists;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Users;
using WindowsFormsApplication1;
using ClientApplication;

namespace Sim
{
    public class PresenterMain
    {
        public IMain _view { get; set; }
        public ITournament _modelTournament { get; set; }
        public ITournamentList _modelTournamentList { get; set; }
        public ILogin _modelLogin { get; set; }
        public IUserList _modelUserList { get; set; }

        public PresenterMain(IMain view, Login login, UserList ul, TournamentList tl)
        {
            this._modelLogin = login;
            this._modelUserList = ul;
            this._modelTournamentList = tl;
            this._view = view;
            this._view.EventLogin += NewLogin;
            this._view.EventNewSignUpWindow += NewSignUpWindow;
            this._view.EventNewTournament += NewTournament;
            this._view.EventRefreshList += RefreshList;
            //this._view.EventSignUp += NewSignUp;
        }

        public void NewLogin(string username, string password)
        {
            Program.ca.sendLogin(username, password);
        }

        public void RefreshList() //string parameter
        {
            Program.ca.sendRefreshRequest();
        }

        //public int NewSignUp(User u)
        //{
        //    return this._modelUserList.AddUser(u);
        //}

        public void NewTournament(Tournament t)
        {
            
            this._modelTournamentList.AddTournament(t);
        }

        public void NewSignUpWindow() //Multipla instanser
        {
            SignUp su = new SignUp(); 
            PresenterSignUp presenter2 = new PresenterSignUp(su, Program.ul);
            su.Show();
        }
    }
}
